
const {resolve}  = require('path')
const r =url =>resolve(__dirname,url)
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')


module.exports ={
    mode:'production',
    devtool:false,
    output:{
        path:r('../mina'),
        filename:'[name].js'
    },
    resolve:{
        alias:{
            utils:r('../utils/util')
        }
    },
    module:{
        rules:[
            {
                test:/\.mina$/,
                loader:'wechat-mina-loader',
                options:{
                    path:r('../'),
                    dist:'./mina'
                }
            },
            {
                test:/\.js$/,
                loader:'babel-loader',
                exclude:/node_modules/,
                options: {
                    presets: ['env']
                    
                }
            },
            {
                test: /\.(sa|sc|c)ss$/,
                use: [
                   MiniCssExtractPlugin.loader,
                  'css-loader',
                  'postcss-loader',
                  'sass-loader',
                ],
            }
        ]
    },
    plugins:[
        new CopyWebpackPlugin([
            {
                from:{
                    glob:'pages/**/*.json',
                    
                },
                to:''
            },{
                from:'static',
                to:'static'
            }
        ]),
        new webpack.optimize.ModuleConcatenationPlugin(),
        // new webpack.optimize.minimize({
        //     souceMap:false
        //   }),

    ]
}